package omg.SongHandling.DataHandling;

import omg.Error.NoConnectionError;
import omg.Error.StreamCreationFailedError;

/**
 * !Note: This si a face stream object, as it doesn't include any actual
 * streaming functionality.
 */
public class StreamSwfOverHttp extends Stream {

    public StreamSwfOverHttp(Song song) throws StreamCreationFailedError, NoConnectionError {
        super(song);
        this.type = "swf/flv";
        if (!StreamSwfOverHttp.isResponsibleFor(song))
            throw new StreamCreationFailedError();
    }

    /**
     * Checks whether an this Stream can handle the audio source associated
     * with the supplied song.
     * @param song the Song to check for
     * @return true, if the parse realizations considers itself responsible
     * for the supplied Song, otherwise false
     */
    public static boolean isResponsibleFor(Song song) {
        String sourceName = song.getLink().toString();
        if ("swf".equalsIgnoreCase(sourceName.substring(sourceName.lastIndexOf('.')+1,sourceName.length())))
            return true;
        return false;
    }

}
